<!DOCTYPE html >
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="Mark Otto, Jacob Thornton, and Bootstrap contributors">
    <meta name="generator" content="Hugo 0.87.0">
    <title>edit page</title>
    <!-- Bootstrap core CSS -->
    <link href="/assets/dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- Custom styles for this template -->
    <link href="/assets/dist/css/dashboard.css" rel="stylesheet">
</head>
<body>
<!--引入topbar-->
<div th:replace="commons/bar::topbar"></div>
<div class="container-fluid">
    <div class="row">
        <!--引入sidebar-->
        <div th:replace="commons/bar::sidebar(activeUri='emps')"></div>

        <main class="col-md-9 ms-sm-auto col-lg-10 px-md-4 ">
            <h1>修改员工信息</h1>
            <form th:action="@{/emp}" method="post">
                <!--发送put请求修改员工数据-->
                <!--
                1、SpringMVC中配置HiddenHttpMethodFilter;（SpringBoot自动配置好的）
                2、页面创建一个post表单
                3、创建一个input项，name="_method";值就是我们指定的请求方式
                4. 传入id 最后保存的时候才知道改的是哪个
                -->
                <input type="hidden" name="_method" value="put" th:if="${emp!=null}"/>
                <input type="hidden" name="id"  th:value="${emp.getId()}">
                <div class="form-floating mb-3">
                    <input name="lastName" type="password" class="form-control" id="floatingLastName"
                           placeholder="floatingLastName" th:value="${emp.getLastName()}">
                    <label for="floatingLastName">LastName</label>
                </div>
                <div class="form-floating mb-3">
                    <input name="email" type="password" class="form-control" id="floatingEmail"
                           placeholder="floatingEmail" th:value="${emp.getEmail()}">
                    <label for="floatingEmail">Email</label>
                </div>
                <div class="form-group mb-3">
                    <label>Gender</label><br/>
                    <div class="form-check form-check-inline">
                        <input class="form-check-input" type="radio" name="gender" value="1"
                               th:checked="${emp.getGender()==1}">
                        <label class="form-check-label">男</label>
                    </div>
                    <div class="form-check form-check-inline">
                        <input class="form-check-input" type="radio" name="gender" value="0"
                               th:checked="${emp.getGender()==0}">
                        <label class="form-check-label">女</label>
                    </div>
                </div>
                <div class="form-group mb-3">
                    <label>department</label>
                    <!--提交的是部门的id-->
                    <select class="form-control" name="DepartmentName">
                        <option th:value="${dept.getDepartmentName()}"
                                th:each="dept:${depts}"
                                th:text="${dept.getDepartmentName()}"
                                th:selected="${emp!=null}?${dept.getDepartmentName() == emp.department}">
                        </option>
                        <!--                    <option th:selected="${emp!=null}?${dept.id == emp.department.id}" th:value="${dept.id}" th:each="dept:${depts}" th:text="${dept.departmentName}">1</option>-->
                    </select>
                </div>
                <div class="form-group">
                    <label>Birth</label>
                    <input name="birth" type="text" class="form-control" placeholder="yyyy/MM/dd"
                           th:value="${#dates.format(emp.birth, 'yyyy/MM/dd')}">
                </div>
                <button type="submit" class="btn btn-primary">修改</button>
            </form>
        </main>
    </div>
</div>


<script src="/assets/dist/js/bootstrap.bundle.min.js"></script>

<script src="https://cdn.jsdelivr.net/npm/feather-icons@4.28.0/dist/feather.min.js"
        integrity="sha384-uO3SXW5IuS1ZpFPKugNNWqTZRRglnUJK6UAZ/gxOX80nxEkN9NcGZTftn6RzhGWE"
        crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/chart.js@2.9.4/dist/Chart.min.js"
        integrity="sha384-zNy6FEbO50N+Cg5wap8IKA4M/ZnLJgzc6w2NqACZaK0u0FXfOWRRJOnQtpZun8ha"
        crossorigin="anonymous"></script>
<script src="/assets/dist/js/dashboard.js"></script>
</body>
</html>
